package com.ruoyi.platform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.platform.domain.TPermanentBlacklistDevice;
import com.ruoyi.platform.service.ITPermanentBlacklistDeviceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 设备号永久黑名单Controller
 * 
 * @author ruoyi
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/device")
public class TPermanentBlacklistDeviceController extends BaseController
{
    @Autowired
    private ITPermanentBlacklistDeviceService tPermanentBlacklistDeviceService;

    /**
     * 查询设备号永久黑名单列表
     */
    @RequiresPermissions("platform:device:list")
    @GetMapping("/list")
    public TableDataInfo list(TPermanentBlacklistDevice tPermanentBlacklistDevice)
    {
        startPage();
        List<TPermanentBlacklistDevice> list = tPermanentBlacklistDeviceService.selectTPermanentBlacklistDeviceList(tPermanentBlacklistDevice);
        return getDataTable(list);
    }

    /**
     * 导出设备号永久黑名单列表
     */
    @RequiresPermissions("platform:device:export")
    @Log(title = "设备号永久黑名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TPermanentBlacklistDevice tPermanentBlacklistDevice)
    {
        List<TPermanentBlacklistDevice> list = tPermanentBlacklistDeviceService.selectTPermanentBlacklistDeviceList(tPermanentBlacklistDevice);
        ExcelUtil<TPermanentBlacklistDevice> util = new ExcelUtil<TPermanentBlacklistDevice>(TPermanentBlacklistDevice.class);
        util.exportExcel(response, list, "设备号永久黑名单数据");
    }

    /**
     * 获取设备号永久黑名单详细信息
     */
    @RequiresPermissions("platform:device:query")
    @GetMapping(value = "/{permanentBlacklistDeviceId}")
    public AjaxResult getInfo(@PathVariable("permanentBlacklistDeviceId") Long permanentBlacklistDeviceId)
    {
        return success(tPermanentBlacklistDeviceService.selectTPermanentBlacklistDeviceByPermanentBlacklistDeviceId(permanentBlacklistDeviceId));
    }

    /**
     * 新增设备号永久黑名单
     */
    @RequiresPermissions("platform:device:add")
    @Log(title = "设备号永久黑名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPermanentBlacklistDevice tPermanentBlacklistDevice)
    {
        return toAjax(tPermanentBlacklistDeviceService.insertTPermanentBlacklistDevice(tPermanentBlacklistDevice));
    }

    /**
     * 修改设备号永久黑名单
     */
    @RequiresPermissions("platform:device:edit")
    @Log(title = "设备号永久黑名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPermanentBlacklistDevice tPermanentBlacklistDevice)
    {
        return toAjax(tPermanentBlacklistDeviceService.updateTPermanentBlacklistDevice(tPermanentBlacklistDevice));
    }

    /**
     * 删除设备号永久黑名单
     */
    @RequiresPermissions("platform:device:remove")
    @Log(title = "设备号永久黑名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{permanentBlacklistDeviceIds}")
    public AjaxResult remove(@PathVariable Long[] permanentBlacklistDeviceIds)
    {
        return toAjax(tPermanentBlacklistDeviceService.deleteTPermanentBlacklistDeviceByPermanentBlacklistDeviceIds(permanentBlacklistDeviceIds));
    }
}
